package com.xbongbong.saas.script.tempenum;

import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.pro.enums.AmountFlagEnum;
import com.xbongbong.paas.field.SaasParticularAttributePoJo;
import com.xbongbong.saas.constant.BasicConstant;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import com.xbongbong.saas.enums.business.RedPaymentSheetEnum;
import com.xbongbong.saas.enums.dictionary.PayMethodEnum;
import com.xbongbong.saas.script.help.InitExplainsHelper;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author feng.zheng
 * @version v1.0
 * @date 2019/3/14 16:26
 * @since v1.0
 */
@Getter
public enum TempRedPaymentSheetEnum {
    //刷脚本专用枚举
    PAYMENT_NO(RedPaymentSheetEnum.PAYMENT_NO),
    BELONG_ID(RedPaymentSheetEnum.BELONG_ID),
    CUSTOMER(RedPaymentSheetEnum.CUSTOMER),
    CONTRACT(RedPaymentSheetEnum.CONTRACT),
    PAYMENT(RedPaymentSheetEnum.PAYMENT),
    PAYMENT_TIME(RedPaymentSheetEnum.PAYMENT_TIME),
    PAY_METHOD(RedPaymentSheetEnum.PAY_METHOD),
    MEMO(RedPaymentSheetEnum.MEMO),
    LINK_SHEET(RedPaymentSheetEnum.LINK_SHEET),
    RED_AMOUNT(RedPaymentSheetEnum.RED_AMOUNT),
    LINK_SHEET_LINKED_TEXT(RedPaymentSheetEnum.LINK_SHEET_LINKED_TEXT);

    private RedPaymentSheetEnum anEnum;

    TempRedPaymentSheetEnum(RedPaymentSheetEnum anEnum) {
        this.anEnum = anEnum;
    }

    public static List<TempRedPaymentSheetEnum> getAllEnum() {
        List<TempRedPaymentSheetEnum> list = new ArrayList<>();
        Collections.addAll(list, values());
        return list;
    }


    /**
     * 初始化支付方式
     *
     * @param fieldAttrEntity 字段解释实体--saas专用
     * @author feng.zheng
     * @date 2019/1/17
     */
    public static void initPayMethod(FieldAttrEntity fieldAttrEntity) {
//        String str = "网银转账,现金,支票,电汇,承兑汇票";
        fieldAttrEntity.setItems(InitExplainsHelper.setCombItemByEnum(PayMethodEnum.class,fieldAttrEntity.getFieldType()));
    }

    public static void initLinkSheet(FieldAttrEntity fieldAttrEntity) {
        SaasParticularAttributePoJo saasParticularAttributePoJo = new SaasParticularAttributePoJo();
        saasParticularAttributePoJo.setRelyAttr(PAYMENT.anEnum.getAttr());
        saasParticularAttributePoJo.setRelyBusiness(XbbRefTypeEnum.PAYMENT.getCode());
        fieldAttrEntity.setSaasParticularAttributePoJo(saasParticularAttributePoJo);
        fieldAttrEntity.setLinkedType(XbbRefTypeEnum.PAYMENT_SHEET.getCode());
        fieldAttrEntity.setLinkedText(LINK_SHEET_LINKED_TEXT.anEnum.getAttr());
    }

    public static void initCustomer(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setLinkedType(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode());
        fieldAttrEntity.setEditable(BasicConstant.ZERO);
    }
    public static void initContract(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setLinkedType(XbbRefTypeEnum.CONTRACT.getCode());
        fieldAttrEntity.setEditable(BasicConstant.ZERO);
    }
    public static void initPayment(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setLinkedType(XbbRefTypeEnum.PAYMENT.getCode());
        fieldAttrEntity.setEditable(BasicConstant.ZERO);
    }

    public static void initRedAmount(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setAmountFlag(AmountFlagEnum.YES.getType());
    }
}
